<?php  

/**
 * Helper for displaying links
 *
 * @since 2011-07-23
 * @author Jakub Kułak <jakub.kulak@gmail.com>
 */
class Zend_View_Helper_Link extends Zend_View_Helper_Abstract 
{ 
    public function link($routeName, $label = null, $class = null) {

        $page = $this->view->navigation()->getContainer()->findOneBy('route', $routeName);
        if (null === $page) {
            throw new Zend_View_Exception('Route "' . $routeName . '" not found.');
        }
        $class = isset($class)?' class="' . $class . '"':'';
        if ( null === $label ) {
            $label =  $this->view->translate($page->getLabel());
        }
        return '<a' . $class . ' href="' . $this->view->translate($this->view->url(array(), $page->getRoute())) . '">' . $label . '</a>';
    }
}